package com.csjy.migration.hnnd.workflow;

import com.csjy.migration.hnnd.BusinessTool;
import com.csjy.migration.hnnd.DbUtil;
import com.csjy.migration.hnnd.ProgramArgument;
import com.csjy.migration.hnnd.annotation.Task;
import com.csjy.migration.hnnd.business.SourceBusinessData;

import java.util.Arrays;
import java.util.Map;


/*    代偿项目移交(item-ask-inst-hand-over-hny)
        phs*/

public class ItemAskInstHandOverHny extends WorkflowMigration{

    public ItemAskInstHandOverHny(DbUtil sourceDbUtil, DbUtil targetDbUtil, SourceBusinessData sourceData, ProgramArgument programArgument, String projectId, String procInstId, Map procInstRow) throws Exception {
        super(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId, procInstRow);
        this.customInitData();
    }

    @Override
    public void customInitData() throws Exception {
        this.curBizType = "dcxmyj";
    }

    @Override
    public void customInsertOrUpdateData() throws Exception {

    }

    @Task("代偿项目移交@项目经理申请移交")
    public void xmjlsqyj() throws Exception {
        this.curModelMap.put("all", new String[]{"task1535511899716xyb","下一步"});

        this.curCustomData.put("coverageMoney",this.getJbpmVarInstValueByName("cassum"));
        this.curCustomData.put("guarantAgreeNo",this.getJbpmVarInstValueByName("assuContractNo"));
        this.curCustomData.put("creditTimeStart",this.getJbpmVarInstValueByName("auditTime"));
        this.curCustomData.put("creditTimeEnd",this.getJbpmVarInstValueByName("assumpTime"));
        if(this.getJbpmVarInstValueByName("managerA") != null && !this.getJbpmVarInstValueByName("managerA").equals("")){
            this.curCustomData.put("managerA",BusinessTool.getEmpCodeByEmpName(this.getJbpmVarInstValueByName("managerA")));
        }
        if(this.getJbpmVarInstValueByName("managerB") != null && !this.getJbpmVarInstValueByName("managerB").equals("")){
            this.curCustomData.put("managerB",BusinessTool.getEmpCodeByEmpName(this.getJbpmVarInstValueByName("managerB")));
        }

        this.curCustomData.put("money",this.getJbpmVarInstValueByName("dcje"));
        this.curCustomData.put("compensatoryType",this.getJbpmVarInstValueByName("dchtp"));
        this.curCustomData.put("amortization", this.getJbpmVarInstValueByName(""));// 他方分摊
        this.curCustomData.put("earnest", this.getJbpmVarInstValueByName("bzje")); // 已缴保证金
        this.curCustomData.put("productName", this.getJbpmVarInstValueByName("assClass"));//产品类型


        this.curAffixTypeCommon = "xmjlsqwj";
        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@BC经理审核")
    public void bcjlsh() throws Exception {
        this.curAffixType = "tjfj";
        this.curModelMap.put("通过", new String[]{"task1535511961372tg","通过"});
        this.curModelMap.put("同意", new String[]{"task1535512080829ty","同意"});
        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@办事处负责人审批")
    public void bscfzrsp() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1535512080829tg","通过"});
        this.curModelMap.put("同意", new String[]{"task1562916465110ty","同意"});
        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@分公司负责人审核")
    public void fgsfzrsh() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1562916465110tg","通过"});
        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@业务副总审核")
    public void ywfzsh() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1562916474390tg","通过"});
        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@法务副总审批")
    public void fwfzsp() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1562916474390tg","通过"});
        // TODO 新版本增加（新系统没有对应的)
        this.curModelMap.put("不通过", new String[]{"task1535512348555tg","不通过"});

        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@总经理审核")
    public void zjlsh() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1535512170717tg","通过"});
        // TODO 新版本增加（新系统没有对应的)
        this.curModelMap.put("不通过", new String[]{"task1535512170717tg","不通过"});

        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@总经理审批")
    public void zjlsp() throws Exception {
        zjlsh();
    }

    @Task("代偿项目移交@保全部经理接收处理")
    public void bhbjljscl() throws Exception {
        fwbjljscl();
    }

    @Task("代偿项目移交@法务部经理接收处理")
    public void fwbjljscl() throws Exception {
        String xmjl = BusinessTool.getEmpCode(this.getJbpmVarInstValueByName("zzrr"));
        this.curCustomData.put("people",xmjl);
        this.curCustomData.put("jwframe_riskLevel", this.getJbpmVarInstValueByName("riskLevel"));
        this.curModelMap.put("通过", new String[]{"task1535512348555tg","通过"});

        // TODO: 新版本流程增加
        this.curModelMap.put("提交总部责任人", new String[]{"task1535512348555tg","通过"});
        this.curModelMap.put("分派到分公司", new String[]{"task1535512348555tg","通过"});

        this.setCommonData(true,null);
        if(xmjl != null) {
            this.targetDbUtil.updateByParams("update nd_project_info set people=? where id = ?"
                , Arrays.asList(xmjl,this.projectId));
        }
    }


    @Task("代偿项目移交@追偿主责任人接收")
    public void zczzrrjs() throws Exception {
        this.curModelMap.put("同意", new String[]{"endty","同意"});
        this.curModelMap.put("不同意", new String[]{"endbty","不同意"});
        this.curModelMap.put("退回", new String[]{"task1535512170717th","退回"});
        this.curModelMap.put("补材料", new String[]{"task1562916749743bzl","补资料"});
        this.curModelMap.put("补资料", new String[]{"task1562916749743bzl","补资料"});

        this.setCommonData(true,null);
    }

    @Task("代偿项目移交@项目经理补充材料")
    public void xmjlbccl() throws Exception {
        xmjlsqyj();
        this.curModelMap.put("提交", new String[] {"task1535512348555tj", "提交"});
    }

    @Task("代偿项目移交@追偿监管人接收")
    public void zcjgrjs() throws Exception {
        bscfzrsp();
    }

    @Task("代偿项目移交@分公司负责人处理")
    public void fgsfzrcl() throws Exception {
        fwbjljscl();
    }


}
